﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cmsservice.Common;
using ServiceStack.Redis;

namespace cmsservice.BLL
{
    public class AssemblyLineBLL
    {
        private static PooledRedisClientManager sPoolAssembly = null;//日志服务器连接池
        public static PooledRedisClientManager AssemblyClientPool
        {
            get
            {
                if (sPoolAssembly == null)
                {
                    string redisIp = System.Configuration.ConfigurationManager.AppSettings["Assembly_RedisMaster"];
                    sPoolAssembly = new PooledRedisClientManager(redisIp);
                }
                return sPoolAssembly;
            }
        }

        private static string AssemblyList = "list:emoney:oper:assemblylist_sso";

        /// <summary>
        /// 
        /// </summary>
        /// <param name="line"></param>
        /// <param name="flagAllWrite">true必须写入日志</param>
        public static void AddAssembly(AssemblyLine line)
        {
            using (RedisClient client = (RedisClient)AssemblyClientPool.GetClient())
            {
                string json = Common.JsonTools.ToJson(line);
                byte[] bValue = Encoding.UTF8.GetBytes(json);
                client.RPush(AssemblyList, bValue);
            }
        }
    }
    
}
